import { defineStore } from "pinia";
import { ref } from "vue";


export const DEFAULT_CONFIG = {
  tightBorder: false,
};

export type ChatConfig = typeof DEFAULT_CONFIG;

export type ChatConfigStore = ChatConfig & {
  reset: () => void;
  update: (updater: (config: ChatConfig) => void) => void;
};

export const useConfigStore = defineStore('config', () => {
  // State
  const tightBorder = ref(DEFAULT_CONFIG.tightBorder);

  // Actions
  function reset() {
    tightBorder.value = DEFAULT_CONFIG.tightBorder;
  }

  function update(updater: (config: ChatConfig) => void) {
    const config = { tightBorder: tightBorder.value };
    updater(config);
    tightBorder.value = config.tightBorder;
  }

  return {
    tightBorder,
    reset,
    update,
  };
});